/**
 * 用户信息
 */
export class User {
    private _access_token: string | undefined;
    private _avatar_url: string | undefined;
    private _avatar_thumb: string | undefined;
    private _avatar_middle: string | undefined;
    private _avatar_big: string | undefined;
    private _expires_in: number | undefined;
    private _name: string | undefined;
    private _en_name: string | undefined;
    private _open_id: string | undefined;
    private _union_id: string | undefined;
    private _email: string | undefined;
    private _user_id: string | undefined;
    private _mobile: string | undefined;
    private _tenant_key: string | undefined;
    private _refresh_expires_in: number | undefined;
    private _refresh_token: string | undefined;
    private _token_type: string | undefined;

    get access_token(): string | undefined {
        return this._access_token;
    }

    set access_token(value: string | undefined) {
        this._access_token = value;
    }

    get avatar_url(): string | undefined {
        return this._avatar_url;
    }

    set avatar_url(value: string | undefined) {
        this._avatar_url = value;
    }

    get avatar_thumb(): string | undefined {
        return this._avatar_thumb;
    }

    set avatar_thumb(value: string | undefined) {
        this._avatar_thumb = value;
    }

    get avatar_middle(): string | undefined {
        return this._avatar_middle;
    }

    set avatar_middle(value: string | undefined) {
        this._avatar_middle = value;
    }

    get avatar_big(): string | undefined {
        return this._avatar_big;
    }

    set avatar_big(value: string | undefined) {
        this._avatar_big = value;
    }

    get expires_in(): number | undefined {
        return this._expires_in;
    }

    set expires_in(value: number | undefined) {
        this._expires_in = value;
    }

    get name(): string | undefined {
        return this._name;
    }

    set name(value: string | undefined) {
        this._name = value;
    }

    get en_name(): string | undefined {
        return this._en_name;
    }

    set en_name(value: string | undefined) {
        this._en_name = value;
    }

    get open_id(): string | undefined {
        return this._open_id;
    }

    set open_id(value: string | undefined) {
        this._open_id = value;
    }

    get union_id(): string | undefined {
        return this._union_id;
    }

    set union_id(value: string | undefined) {
        this._union_id = value;
    }

    get email(): string | undefined {
        return this._email;
    }

    set email(value: string | undefined) {
        this._email = value;
    }

    get user_id(): string | undefined {
        return this._user_id;
    }

    set user_id(value: string | undefined) {
        this._user_id = value;
    }

    get mobile(): string | undefined {
        return this._mobile;
    }

    set mobile(value: string | undefined) {
        this._mobile = value;
    }

    get tenant_key(): string | undefined {
        return this._tenant_key;
    }

    set tenant_key(value: string | undefined) {
        this._tenant_key = value;
    }

    get refresh_expires_in(): number | undefined {
        return this._refresh_expires_in;
    }

    set refresh_expires_in(value: number | undefined) {
        this._refresh_expires_in = value;
    }

    get refresh_token(): string | undefined {
        return this._refresh_token;
    }

    set refresh_token(value: string | undefined) {
        this._refresh_token = value;
    }

    get token_type(): string | undefined {
        return this._token_type;
    }

    set token_type(value: string | undefined) {
        this._token_type = value;
    }
}

export class UserWrapper {
    private _user: User | undefined;

    get user(): User | undefined {
        return this._user;
    }

    set user(value: User | undefined) {
        this._user = value;
    }
}

/**
 * 用户包装类
 */
export class UserInfoWrapper {
    // Map<string, User> key 是由 {appId: '', appSecret: ''} sha1 获取。因此可以反查
    private _userInfo: Map<string, UserWrapper> | undefined = new Map<string, UserWrapper>();

    // 唯一对象
    constructor() {
    }

    get userInfo(): Map<string, UserWrapper> | undefined {
        return this._userInfo;
    }

    set userInfo(value: Map<string, UserWrapper> | undefined) {
        this._userInfo = value;
    }
}

/**
 * 应用包装类
 */
export class AppInfoWrapper {
    // Map<string, User> key 是 app_id， value 是对应的应用下的多个用户
    private _appInfo: Map<string, UserInfoWrapper> | undefined = new Map<string, UserInfoWrapper>();
    // 唯一对象
    private static instance: AppInfoWrapper;

    private constructor() {
    }

    public static getInstance(): AppInfoWrapper {
        if (!AppInfoWrapper.instance) {
            AppInfoWrapper.instance = new AppInfoWrapper();
        }
        return this.instance;
    }

    get appInfo(): Map<string, UserInfoWrapper> | undefined {
        return this._appInfo;
    }

    set appInfo(value: Map<string, UserInfoWrapper> | undefined) {
        this._appInfo = value;
    }
}
